import {createSlice} from '@reduxjs/toolkit'

const orderSlice=createSlice({
  name: 'order',
  initialState:{
    psgArr:[
      {name: '王啊召',idcard: '419001199811021676',ticketType: '成人票'},
       {name: '赵四',idcard: '500105200002022601',ticketType: '学生票'},
    ]
  },

  reducers:{
    addPsg(state,action){
      state.psgArr.push(action.payload)
    },
    removePsgByIndex(state,action){
      state.psgArr=state.psgArr.filter((item,i)=> i !== action.payload)
    }
  }
})

export default orderSlice.reducer
export const {addPsg,removePsgByIndex} =orderSlice.actions